package de.g18.llmaa.gui.workspace.internalFrame.product.key.verleihVerwaltung;

import java.util.ArrayList;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

import de.g18.llmaa.logic.vos.VOPerson;
import de.g18.llmaa.logic.vos.VOPerson_Schueler;

public class TableModel_Person implements TableModel {

	private ArrayList<VOPerson> listPerson;

	public TableModel_Person(ArrayList<VOPerson> listPerson) {
		this.listPerson = listPerson;
	}

	@Override
	public void addTableModelListener(TableModelListener arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public Class<?> getColumnClass(int arg0) {
		switch (arg0) {
		case 0:

			return String.class;
		case 1:

			return String.class;
		case 2:
			return String.class;

		default:
			break;
		}
		return null;
	}

	@Override
	public int getColumnCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	@Override
	public String getColumnName(int arg0) {
		switch (arg0) {
		case 0:

			return "Vorname";

		case 1:

			return "Nachname";

		case 2:

			return "Typ";

		default:
			break;
		}
		return null;
	}

	@Override
	public int getRowCount() {
		// TODO Auto-generated method stub
		return listPerson.size();
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
		switch (arg1) {
		case 0:

			return listPerson.get(arg0).getVorName();

		case 1:

			return listPerson.get(arg0).getNachName();

		case 2:

			if (listPerson.get(arg0) instanceof VOPerson_Schueler)
				return "Schüler";

			if (listPerson.get(arg0) instanceof VOPerson)
				return "Lehrer";

			return "";

		default:
			return "";
		}

	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void removeTableModelListener(TableModelListener arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

	public VOPerson getValue(int selectedRow) {
		return listPerson.get(selectedRow);

	}

}
